home *** CD-ROM | disk | FTP | other *** search
- unit Win16tb;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, Menus, ShellAPI;
-
- type
- TCCTaskBarForm = class(TForm)
- Panel1: TPanel;
- BitBtn1: TBitBtn;
- BitBtn2: TBitBtn;
- BitBtn3: TBitBtn;
- BitBtn4: TBitBtn;
- BitBtn5: TBitBtn;
- BitBtn6: TBitBtn;
- BitBtn7: TBitBtn;
- OpenDialog1: TOpenDialog;
- PopupMenu1: TPopupMenu;
- StartAsIcon1: TMenuItem;
- AddFile1: TMenuItem;
- ShowOnBottom1: TMenuItem;
- ShowOnTop1: TMenuItem;
- PopupMenu2: TPopupMenu;
- NewFile1: TMenuItem;
- MoveUp1: TMenuItem;
- MoveDown1: TMenuItem;
- Delete1: TMenuItem;
- procedure BitBtn2Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure BitBtn1Click(Sender: TObject);
- procedure FormDestroy(Sender: TObject);
- procedure BitBtn5Click(Sender: TObject);
- procedure BitBtn6Click(Sender: TObject);
- procedure BitBtn7Click(Sender: TObject);
- procedure BitBtn3Click(Sender: TObject);
- procedure BitBtn4Click(Sender: TObject);
- procedure StartAsIcon1Click(Sender: TObject);
- procedure ShowOnBottom1Click(Sender: TObject);
- procedure ShowOnTop1Click(Sender: TObject);
- procedure AddFile1Click(Sender: TObject);
- procedure NewFile1Click(Sender: TObject);
- procedure Delete1Click(Sender: TObject);
- procedure MoveUp1Click(Sender: TObject);
- procedure MoveDown1Click(Sender: TObject);
- procedure BitBtn5MouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure BitBtn6MouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure BitBtn7MouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure BitBtn5MouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure BitBtn6MouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure BitBtn7MouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- private
- { Private declarations }
- public
- { Public declarations }
- procedure ReadTheTaskBarIniFile; { This reads in the program data }
- procedure WriteTheTaskBarIniFile; { This writes out the program data }
- procedure SetUpTheTaskBar; { This sets up the icon/data array }
- procedure DeleteTasksFrom( TheTask : Integer ); { Fiddle w record array }
- procedure ReplaceFile( CurrentSelection : Integer ); { Replace file }
- end; { and puts the first 3 into view }
- PTBRecord = ^TBRecord; { Define pointer type }
- TBRecord = record { Define record type }
- TheName : String; { Holds program name }
- TheBitmap : TBitmap; { Holds bitmpd icon }
- TheIcon : TIcon;
- end;
- PTBArray = array[ 1 .. 255 ] of PTBRecord; { Working data array }
-
- var
- CCTaskBarForm: TCCTaskBarForm;
- ThePTBArray : PTBArray; { This holds the data array from INI }
- TotalTaskEntries : Integer; { This is the total items to use }
- CurrentTaskPointer : Integer; { This is the position to start disp }
- DeleteMode : Boolean; { This is a flag indicating deletion }
- ShowPosition : Integer; { This handles staring at top/bottom }
- StartingState : Integer; { This handles normal/icon startup }
- TotalTaskPointers : Integer; { This keeps track of the total tasks}
- CurrentTaksPointer : Integer; { This holds current task to run }
- ActiveButton : TBitBtn; { This holds the identity of the btn }
- SaveStartupDir : String; { This holds the starting directory }
- implementation
-
- {$R *.DFM}
-
- uses
- IniFiles ; { Ini file handler unit }
-
- const
-
- TaskBarIniFileName = 'CCTSKBAR.INI'; { Make this a constant to save stack space }
-
-
- function ShellExec(const PathStr, CmdStr, DirStr: string;
- PrintIt: boolean; Show: word; Wait: boolean): boolean;
- var
- Inst: THandle;
- Path, CmdLine, Dir: PChar;
- Op: array[0..5] of Char;
- AppWin: hWnd;
- Valid: Bool;
- begin
- if PrintIt then StrPCopy(Op, 'print') else StrPCopy(Op, 'open');
- { Get memory for PChars }
- GetMem(Path, Length(PathStr)+1);
- GetMem(CmdLine, Length(CmdStr)+1);
- GetMem(Dir, Length(DirStr)+1);
- try
- { Copy strings to PChars }
- StrPCopy(Path, PathStr);
- StrPCopy(CmdLine, CmdStr);
- StrPCopy(Dir, DirStr);
- { Execute file }
- Inst := ShellExecute(0, Op, Path, CmdLine, Dir, Show);
- { If 32 or less, an error occurred }
- if Inst <= 32 then Result := False else
- begin
- if Wait then
- begin
- { Loop while program is running }
- while GetModuleUsage(Inst) <> 0 do
- Application.ProcessMessages;
- { Acknowledge error from last iteration of loop }
- OutputDebugString('--> Please ignore the previous error'#10#13);
- end;
- Result := True;
- end;
- finally
- { Ensure memory is freed }
- FreeMem(Path, Length(PathStr)+1);
- FreeMem(CmdLine, Length(CmdStr)+1);
- FreeMem(Dir, Length(DirStr)+1);
- end;
- end;
-
- procedure TCCTaskBarForm.ReplaceFile( CurrentSelection : Integer );
- var ThePChar : PChar;
- TheOtherPChar ,
- TheResultPChar : PChar;
- TheExt ,
- TempString : String;
- begin
- GetMem( ThePChar , 255 );
- if OpenDialog1.Execute then
- begin
- with ThePTBArray[ CurrentSelection ]^ do
- begin
- TheName := OpenDialog1.Filename;
- TheExt := Uppercase( ExtractFileExt( TheName ));
- if (( TheExt <> '.EXE' ) and ( TheExt <> '.BAT' ) and
- ( TheExt <> '.PIF' ) and ( TheExt <> '.COM' )) then
- begin
- GetMem( TheOtherPChar , 255 );
- GetMem( TheResultPChar , 255 );
- StrPCopy( ThePChar, TheName );
- StrPCopy( TheOtherPChar , ExtractFilePath( TheName ));
- if FindExecutable( ThePChar , TheOtherPChar , TheResultPChar ) > 31 then
- begin
- TheIcon.Free;
- TheIcon := TIcon.Create;
- TheIcon.Handle := ExtractIcon( hInstance , TheResultPchar , 0 );
- end
- else
- begin
- MessageDlg( 'No Application Registered for this File Type!',mtError,[mbok],0);
- TheIcon.Handle := 0;
- end;
- FreeMem( TheOtherPChar , 255 );
- FreeMem( TheResultPChar , 255 );
- end
- else
- begin
- StrPCopy( ThePChar , TheName );
- TheIcon.Free;
- TheIcon := TIcon.Create;
- TheIcon.Handle := ExtractIcon( hInstance , ThePChar , 0 );
- end;
- if TheIcon.Handle <> 0 then
- begin
- TheBitmap.Canvas.Draw( 1,1,TheIcon );
- end
- else
- begin
- TheBitmap.LoadFromFile( SaveStartupDir +'\Default.bmp' );
- end;
- end;
- SetupTheTaskBar;
- end;
- FreeMem( ThePChar , 255 );
- end;
-
- procedure TCCTaskBarForm.DeleteTasksFrom( TheTask : Integer );
- var Counter_1 : Integer;
- begin
- if TheTask = TotalTaskEntries then
- begin
- ThePTBArray[ TheTask ]^.TheName := '';
- ThePTBArray[ TheTask ]^.TheBitmap.LoadFromFile( SaveStartupDir + '\NOFILE.BMP' );
- TotalTaskEntries := TotalTaskEntries - 1;
- end
- else
- begin
- for Counter_1 := TheTask + 1 to TotalTaskEntries do
- begin
- with ThePTBArray[ Counter_1 ]^ do
- begin
- ThePTBArray[ Counter_1 - 1 ]^.TheName := TheName;
- ThePTBArray[ Counter_1 - 1 ]^.TheBitmap.Canvas.Draw( 0 , 0 , TheIcon );
- end;
- end;
- if TotalTaskEntries > 3 then
- begin
- ThePTBArray[ TotalTaskEntries ]^.TheBitmap.Free;
- ThePTBArray[ TotalTaskEntries ]^.TheIcon.Free;
- Dispose( ThePTBArray[ TotalTaskEntries ] );
- TotalTaskEntries := TotalTaskEntries - 1;
- end
- else
- begin
- ThePTBArray[ TotalTaskEntries ]^.TheName := '';
- ThePTBArray[ TotalTaskEntries ]^.TheBitmap.LoadFromFile( SaveStartupDir + '\NOFILE.BMP' );
- TotalTaskEntries := TotalTaskEntries - 1;
- end;
- end;
- end;
-
- procedure TCCTaskBarForm.SetupTheTaskBar;
- var Counter_1 : Integer;
- WorkingPointer : Integer;
- begin
- if TotalTaskEntries < 3 then
- begin
- case TotalTaskEntries of
- 0 : begin
- BitBtn5.Caption := 'No File';
- BitBtn5.Glyph.LoadFromfile( SaveStartupDir + '\NoFile.BMP' );
- BitBtn6.Caption := 'No File';
- BitBtn6.Glyph.LoadFromfile( SaveStartupDir + '\NoFile.BMP' );
- BitBtn7.Caption := 'No File';
- BitBtn7.Glyph.LoadFromfile( SaveStartupDir + '\NoFile.BMP' );
- end;
- 1 : begin
- BitBtn6.Caption := 'No File';
- BitBtn6.Glyph.LoadFromfile( SaveStartupDir + '\NoFile.BMP' );
- BitBtn7.Caption := 'No File';
- BitBtn7.Glyph.LoadFromfile( SaveStartupDir + '\NoFile.BMP' );
- end;
- 2 : begin
- BitBtn7.Caption := 'No File';
- BitBtn7.Glyph.LoadFromfile( SaveStartupDir + '\NoFile.BMP' );
- end;
- end;
- end;
- WorkingPointer := CurrentTaskPointer - 1;
- for Counter_1 := 1 to 3 do
- begin
- WorkingPointer := WorkingPointer + 1;
- if WorkingPointer > TotalTaskEntries then break;
- with ThePTBArray[ WorkingPointer ]^ do
- begin
- case Counter_1 of
- 1 : begin
- BitBtn5.Caption := ExtractFileName( TheName );
- BitBtn5.Glyph := TheBitmap;
- end;
- 2 : begin
- BitBtn6.Caption := ExtractFileName( TheName );
- BitBtn6.Glyph := TheBitmap;
- end;
- 3 : begin
- BitBtn7.Caption := ExtractFileName( TheName );
- BitBtn7.Glyph := TheBitmap;
- end;
- end;
- end;
- end;
- if TotalTaskEntries > 3 then BitBtn4.Enabled := true
- else BitBtn4.Enabled := false;
- if CurrentTaskPointer > 1 then BitBtn3.Enabled := true
- else BitBtn3.Enabled := false;
- end;
-
- { This procedure reads in the configuration from an INI file }
- procedure TCCTaskBarForm.ReadTheTaskBarIniFile;
- var
- { The excellent TIniFile object handles the complexity of Windows INI files! }
- TheIniFile : TIniFile;
- TempString,
- TempString2 : String;
- Counter_1 : Integer;
- ThePChar : PChar;
- TheFileCounterString : String;
-
- begin
- GetMem( ThePchar , 255 );
- CurrentTaskPointer := 1;
- { Combine assignfile and reset into one call with create }
- TheIniFile := TIniFile.Create( TaskBarIniFileName );
- { Use a try block to make sure the ini file is closed by free call }
- try
- { Use the Tinifile object's read methods to get the configuration data }
- with TheIniFile do
- begin
- { Use readinteger to get the total taskbar entries, with default of 0 for new file }
- TotalTaskEntries := ReadInteger( 'Setup', 'TotalEntries', 0 );
- { Use readinteger to get the total taskbar entries, with default of 0 for new file }
- ShowPosition := ReadInteger( 'Setup', 'StartPosition', 0 );
- { Use readinteger to get the total taskbar entries, with default of 0 for new file }
- StartingState := ReadInteger( 'Setup', 'StartState', 1 );
- if TotalTaskEntries = 0 then
- begin
- GetWindowsDirectory( ThePChar , 255 );
- TempString2 := StrPas( ThePChar );
- TempString := TempString2;
- if FileExists( TempString + '\PBRUSH.EXE' ) then
- begin
- New( ThePTBArray[ 1 ] );
- with ThePTBArray[ 1 ]^ do
- begin
- TempString := TempString + '\PBRUSH.EXE';
- TheName := TempString;
- TheBitmap := TBitmap.Create;
- TheBitmap.Height := 32;
- TheBitmap.Width := 32;
- StrPCopy( ThePChar , TempString );
- TheIcon := TIcon.Create;
- TheIcon.Handle := ExtractIcon( hInstance , ThePChar , 0 );
- if TheIcon.Handle <> 0 then
- begin
- TheBitmap.Canvas.Draw( 1,1,TheIcon );
- end
- else
- begin
- TheBitmap.LoadFromFile( SaveStartupDir + '\Default.bmp' );
- end;
- end;
- TotalTaskEntries := 1;
- end;
- TempString := TempString2;
- if FileExists( TempString + '\WRITE.EXE' ) then
- begin
- New( ThePTBArray[ 2 ] );
- with ThePTBArray[ 2 ]^ do
- begin
- TempString := TempString + '\WRITE.EXE';
- TheName := TempString;
- TheBitmap := TBitmap.Create;
- TheBitmap.Height := 32;
- TheBitmap.Width := 32;
- StrPCopy( ThePChar , TempString );
- TheIcon := TIcon.Create;
- TheIcon.Handle := ExtractIcon( hInstance , ThePChar , 0 );
- if TheIcon.Handle <> 0 then
- begin
- TheBitmap.Canvas.Draw( 1,1,TheIcon );
- end
- else
- begin
- TheBitmap.LoadFromFile( SaveStartupDir + '\Default.bmp' );
- end;
- TotalTaskEntries := TotalTaskEntries + 1;
- end;
- end;
- TempString := TempString2;
- if FileExists( TempString + '\CONTROL.EXE' ) then
- begin
- New( ThePTBArray[ 3 ] );
- with ThePTBArray[ 3 ]^ do
- begin
- TempString := TempString + '\CONTROL.EXE';
- TheName := TempString;
- TheBitmap := TBitmap.Create;
- TheBitmap.Height := 32;
- TheBitmap.Width := 32;
- StrPCopy( ThePChar , TempString );
- TheIcon := TIcon.Create;
- TheIcon.Handle := ExtractIcon( hInstance , ThePChar , 0 );
- if TheIcon.Handle <> 0 then
- begin
- TheBitmap.Canvas.Draw( 1,1,TheIcon );
- end
- else
- begin
- TheBitmap.LoadFromFile( SaveStartupDir + '\Default.bmp' );
- end;
- end;
- TotalTaskEntries := TotalTaskEntries + 1;
- end;
- end
- else
- begin
- for Counter_1 := 1 to TotalTaskEntries do
- begin
- TheFileCounterString := 'FileNo_' + IntToStr( Counter_1 );
- TempString := ReadString( 'FileList', TheFileCounterString, '' );
- New( ThePTBArray[ Counter_1 ] );
- with ThePTBArray[ Counter_1 ]^ do
- begin
- TheName := TempString;
- TheBitmap := TBitmap.Create;
- TheBitmap.Height := 32;
- TheBitmap.Width := 32;
- StrPCopy( ThePChar , TempString );
- TheIcon := TIcon.Create;
- TheIcon.Handle := ExtractIcon( hInstance , ThePChar , 0 );
- if TheIcon.Handle <> 0 then
- begin
- TheBitmap.Canvas.Draw( 1,1,TheIcon );
- end
- else
- begin
- TheBitmap.LoadFromFile( SaveStartupDir + '\Default.bmp' );
- end;
- end;
- end;
- end;
- end;
- finally
- { Regardless of success or failure, free the TIniFile object }
- TheIniFile.Free;
- FreeMem( ThePChar , 255 );
- end;
- end;
-
- { This procedure writes out the configuration to an INI file }
- procedure TCCTaskBarForm.WriteTheTaskBarIniFile;
- var
- { Again use the very useful TIniFile object to encapsulate Windows INI files }
- TheIniFile : TIniFile;
- TempString : String;
- Counter_1 : Integer;
- begin
- { Combine an AssignFile and Reset call into the create method }
- TheIniFile := TIniFile.Create( TaskBarIniFileName );
- try
- { Use the TIniFile object's methods to write out the data }
- with TheIniFile do
- begin
- { Use writeinteger to send the total entries in the program }
- WriteInteger( 'Setup' , 'TotalEntries' , TotalTaskEntries );
- { Use writeinteger to send the total entries in the program }
- WriteInteger( 'Setup' , 'StartPosition' , ShowPosition );
- { Use writeinteger to send the total entries in the program }
- WriteInteger( 'Setup' , 'StartState' , StartingState );
- for Counter_1 := 1 to TotalTaskEntries do
- begin
- TempString := 'FileNo_' + IntToStr( Counter_1 );
- { Use writestring to send the Working directory for image files }
- WriteString( 'FileList' , TempString , ThePTBArray[ Counter_1 ]^.TheName );
- end;
- end;
- finally
- { Regardless of above calls, free the TIniFile object }
- TheIniFile.Free;
- end;
- end;
-
-
- { This was written by Delphi; use it to simply close the form since }
- { the INI file is updated continually }
- procedure TCCTaskBarForm.BitBtn2Click(Sender: TObject);
- begin
- { Go bye bye }
- close;
- end;
-
- { This was written by Delphi; use it to size the form on the bottom and }
- { place the buttons according to screen size. Then read in the INI file }
- { and set up the data lists and set the first three buttons (or less.) }
- procedure TCCTaskBarForm.FormCreate(Sender: TObject);
- var WorkingSpace , { This is the basic area to work with }
- WorkingDivision , { If more than enough use this for lng }
- WorkingLength : Integer; { If less than enough use this for len }
- begin
- {GlobalUpdate := CCFMUpdate;}
- GetDir( 0 , SaveStartupDir );
- { Set to the screen's width }
- Width := Screen.Width - 2;
- { Move to the left edge }
- Left := 1;
- { Set the exit button's position }
- BitBtn2.Left := Screen.Width - 145;
- { Set the right scroll button's position }
- BitBtn4.Left := BitBtn2.Left - 45;
- { Determine how much room is left }
- WorkingSpace := BitBtn4.left - 200;
- { if plenty of room spread out }
- if WorkingSpace >= 575 then
- begin
- { Divide into 3 chunks }
- WorkingDivision := WorkingSpace div 3;
- { Start at the left edge }
- BitBtn5.Left := 200;
- { Move across one }
- BitBtn6.Left := 210 + WorkingDivision;
- { Move across two }
- BitBtn7.Left := 220 + WorkingDivision * 2;
- end
- else
- begin { Narrow the buttons down to fit the available space }
- { Divide into 3 chunks }
- WorkingLength := ( WorkingSpace div 3 );
- { Set the button widths to less than the chunks }
- BitBtn5.Width := WorkingLength - 15;
- BitBtn6.Width := WorkingLength - 15;
- BitBtn7.Width := WorkingLength - 15;
- { Start at the left edge }
- BitBtn5.left := 200;
- { Move across one }
- BitBtn6.Left := 210 + WorkingLength;
- { Move across two }
- BitBtn7.Left := 220 + ( WorkingLength * 2 );
- end;
- { Read in the INI file data and initialize }
- ReadTheTaskBarIniFile;
- { Move to the bottom of the screen }
- if ShowPosition = 0 then Top := Screen.Height - 90 else Top := 1;
- if StartingState = 0 then
- begin
- WindowState := wsMinimized;
- StartAsIcon1.Checked := true;
- end
- else
- begin
- windowstate := wsnormal;
- StartAsIcon1.Checked := false;
- end;
- SetUpTheTaskBar;
- CurrentTaskPointer := 1;
- end;
-
- { Delphi wrote this; use it to minimize the form so icons can be seen }
- { (since have put in an (invisible) system box, double clicking the }
- { icon will bring back up to max state.) }
- procedure TCCTaskBarForm.BitBtn1Click(Sender: TObject);
- begin
- { Turn into an icon for user friendliness }
- WindowState := wsMinimized;
- end;
-
- { Delphi wrote this; use it to clean up the memory used by the records array }
- procedure TCCTaskBarForm.FormDestroy(Sender: TObject);
- var Counter_1 : Integer;
- begin
- for Counter_1 := 1 to TotalTaskEntries do
- begin
- ThePTBarray[ Counter_1 ]^.TheBitmap.Free;
- ThePTBArray[ Counter_1 ]^.TheIcon.Free;
- Dispose( ThePTBArray[ Counter_1 ] );
- end;
- end;
-
- procedure TCCTaskBarForm.BitBtn5Click(Sender: TObject);
- var
- TheActiveWindow : HWnd;
- TheFileNametoShell : String;
- TheWindowList : Pointer;
- begin
- if TotalTaskEntries = 0 then exit;
- TheFileNametoShell := ThePTBArray[ CurrentTaskPointer ]^.Thename;
- if TheFileNametoShell = '' then exit;
- TheWindowList := DisableTaskWindows( 0 );
- TheActiveWindow := GetActiveWindow;
- try
- if not ShellExec( TheFileNametoShell , '' , '', false ,
- SW_SHOWNORMAL , false ) then
- MessageDlg('Could not Execute Task!', mtInformation, [mbOK], 0);
- finally
- EnableTaskWindows( TheWindowList );
- SetActiveWindow( TheActiveWindow );
- end;
- end;
-
- procedure TCCTaskBarForm.BitBtn6Click(Sender: TObject);
- var
- TheActiveWindow : HWnd;
- TheFileNametoShell : String;
- TheWindowList : Pointer;
- begin
- if CurrentTaskPointer + 1 > TotalTaskEntries then Exit;
- TheFileNametoShell := ThePTBArray[ CurrentTaskPointer + 1 ]^.Thename;
- TheWindowList := DisableTaskWindows( 0 );
- TheActiveWindow := GetActiveWindow;
- try
- if not ShellExec( TheFileNametoShell , '' , '', false ,
- SW_SHOWNORMAL , false ) then
- MessageDlg('Could not Execute Task!', mtInformation, [mbOK], 0);
- finally
- EnableTaskWindows( TheWindowList );
- SetActiveWindow( TheActiveWindow );
- end;
- end;
-
- procedure TCCTaskBarForm.BitBtn7Click(Sender: TObject);
- var
- TheActiveWindow : HWnd;
- TheFileNametoShell : String;
- TheWindowList : Pointer;
- begin
- if CurrentTaskPointer + 2 > TotalTaskEntries then exit;
- TheFileNametoShell := ThePTBArray[ CurrentTaskPointer + 2 ]^.Thename;
- TheWindowList := DisableTaskWindows( 0 );
- TheActiveWindow := GetActiveWindow;
- try
- if not ShellExec( TheFileNametoShell , '' , '', false ,
- SW_SHOWNORMAL , false ) then
- MessageDlg('Could not Execute Task!', mtInformation, [mbOK], 0);
- finally
- EnableTaskWindows( TheWindowList );
- SetActiveWindow( TheActiveWindow );
- end;
- end;
-
- { Delphi wrote this; use it to move the button list one place left }
- procedure TCCTaskBarForm.BitBtn3Click(Sender: TObject);
- begin
- if CurrentTaskPointer = 1 then exit else
- begin
- CurrentTaskPointer := CurrentTaskPointer - 1;
- SetUpTheTaskBar;
- if CurrentTaskPointer = 1 then BitBtn3.Enabled := false;
- if CurrentTaskPointer < ( TotalTaskEntries - 2 ) then
- BitBtn4.Enabled := true;
- end;
- end;
-
- { Delphi wrote this; use it to move the button list one place right }
- procedure TCCTaskBarForm.BitBtn4Click(Sender: TObject);
- begin
- if CurrentTaskPointer >= ( TotalTaskEntries - 2 ) then exit else
- begin
- CurrentTaskPointer := CurrentTaskPointer + 1;
- SetUpTheTaskBar;
- if CurrentTaskPointer = ( TotalTaskEntries - 2 ) then
- BitBtn4.Enabled := false;
- if CurrentTaskPointer > 1 then BitBtn3.Enabled := true;
- end;
- end;
-
- procedure TCCTaskBarForm.StartAsIcon1Click(Sender: TObject);
- begin
- if StartingState = 0 then
- begin
- StartingState := 1;
- StartAsIcon1.Checked := false;
- end
- else
- begin
- StartingState := 0;
- StartAsIcon1.checked := true;
- end;
- WriteTheTaskBarIniFile;
- end;
-
- procedure TCCTaskBarForm.ShowOnBottom1Click(Sender: TObject);
- begin
- ShowPosition := 0;
- ShowOnBottom1.Checked := true;
- ShowOnTop1.Checked := false;
- WriteTheTaskBarIniFile;
- if Top = 1 then
- begin
- Top := Screen.Height - 90;
- end;
- end;
-
- procedure TCCTaskBarForm.ShowOnTop1Click(Sender: TObject);
- begin
- ShowPosition := 1;
- ShowOnBottom1.Checked := false;
- ShowOnTop1.Checked := true;
- WriteTheTaskBarIniFile;
- if Top <> 1 then
- begin
- Top := 1;
- end;
- end;
-
- procedure TCCTaskBarForm.AddFile1Click(Sender: TObject);
- var ThePChar ,
- TheOtherPChar,
- TheResultPChar : PChar;
- TheExt ,
- TempString : String;
- begin
- if TotalTaskEntries = 255 then
- begin
- MessageDlg( 'Maximum Taskbar Entries Reached!',mtError,[mbOk],0);
- exit;
- end;
- GetMem( ThePChar , 255 );
- if OpenDialog1.Execute then
- begin
- TotalTaskEntries := TotalTaskEntries + 1;
- New( ThePTBArray[ TotalTaskEntries ] );
- with ThePTBArray[ TotalTaskEntries ]^ do
- begin
- TheName := OpenDialog1.Filename;
- TheBitmap := TBitmap.Create;
- TheIcon := TIcon.Create;
- TheBitmap.Height := 32;
- TheBitmap.Width := 32;
- TheExt := Uppercase( ExtractFileExt( TheName ));
- if (( TheExt <> '.EXE' ) and ( TheExt <> '.BAT' ) and
- ( TheExt <> '.PIF' ) and ( TheExt <> '.COM' )) then
- begin
- GetMem( TheOtherPChar , 255 );
- GetMem( TheResultPChar , 255 );
- StrPCopy( ThePChar, TheName );
- StrPCopy( TheOtherPChar , ExtractFilePath( TheName ));
- if FindExecutable( ThePChar , TheOtherPChar , TheResultPChar ) > 31 then
- begin
- TheIcon.Handle := ExtractIcon( hInstance , TheResultPchar , 0 );
- end
- else
- begin
- MessageDlg( 'No Application Registered for this File Type!',mtError,[mbok],0);
- TheIcon.Handle := 0;
- end;
- FreeMem( TheOtherPChar , 255 );
- FreeMem( TheResultPChar , 255 );
- end
- else
- begin
- StrPCopy( ThePChar , TheName );
- TheIcon := TIcon.Create;
- TheIcon.Handle := ExtractIcon( hInstance , ThePChar , 0 );
- end;
- if TheIcon.Handle <> 0 then
- begin
- TheBitmap.Canvas.Draw( 1,1,TheIcon );
- end
- else
- begin
- TheBitmap.LoadFromFile( SaveStartupDir + '\Default.bmp' );
- end;
- end;
- SetupTheTaskBar;
- end;
- FreeMem( ThePChar , 255 );
- if TotalTaskEntries = 255 then AddFile1.Enabled := false;
- end;
-
- procedure TCCTaskBarForm.NewFile1Click(Sender: TObject);
- begin
- if ActiveButton = BitBtn5 then
- begin
- if TotalTaskEntries = 0 then exit;
- Replacefile( CurrentTaskPointer );
- SetUpTheTaskbar;
- exit;
- end;
- if ActiveButton = BitBtn6 then
- begin
- If CurrentTaskPointer + 1 > TotalTaskEntries then exit;
- Replacefile( CurrentTaskPointer + 1 );
- SetUpTheTaskbar;
- exit;
- end;
- if ActiveButton = BitBtn7 then
- begin
- if CurrentTaskPointer + 2 > TotalTaskEntries then exit;
- Replacefile( CurrentTaskPointer + 2 );
- SetUpTheTaskbar;
- exit;
- end;
- end;
-
- procedure TCCTaskBarForm.Delete1Click(Sender: TObject);
- begin
- if ActiveButton = BitBtn5 then
- begin
- if TotalTaskEntries = 0 then exit;
- DeleteTasksFrom( CurrentTaskPointer );
- AddFile1.Enabled := true;
- SetUpTheTaskbar;
- exit;
- end;
- if ActiveButton = BitBtn6 then
- begin
- If CurrentTaskPointer + 1 > TotalTaskEntries then exit;
- DeleteTasksFrom( CurrentTaskPointer + 1 );
- AddFile1.Enabled := true;
- SetUpTheTaskbar;
- exit;
- end;
- if ActiveButton = BitBtn7 then
- begin
- if CurrentTaskPointer + 2 > TotalTaskEntries then exit;
- DeleteTasksFrom( CurrentTaskPointer + 2 );
- AddFile1.enabled := true;
- SetUpTheTaskbar;
- exit;
- end;
- end;
-
- procedure TCCTaskBarForm.MoveUp1Click(Sender: TObject);
- var HoldingRecord : TBRecord;
- begin
- if ActiveButton = BitBtn5 then
- begin
- if TotalTaskEntries = 0 then exit;
- if CurrentTaskPointer = 1 then exit;
- HoldingRecord := ThePTBArray[ CurrentTaskPointer - 1 ]^;
- ThePTBArray[ CurrentTaskPointer - 1 ]^ :=
- ThePTBArray[ CurrentTaskPointer ]^;
- ThePTBArray[ CurrentTaskPointer ]^ := HoldingRecord;
- SetUpTheTaskbar;
- exit;
- end;
- if ActiveButton = BitBtn6 then
- begin
- If CurrentTaskPointer + 1 > TotalTaskEntries then exit;
- HoldingRecord := ThePTBArray[ CurrentTaskPointer ]^;
- ThePTBArray[ CurrentTaskPointer ]^ :=
- ThePTBArray[ CurrentTaskPointer + 1 ]^;
- ThePTBArray[ CurrentTaskPointer + 1 ]^ := HoldingRecord;
- SetUpTheTaskbar;
- exit;
- end;
- if ActiveButton = BitBtn7 then
- begin
- if CurrentTaskPointer + 2 > TotalTaskEntries then exit;
- HoldingRecord := ThePTBArray[ CurrentTaskPointer + 1 ]^;
- ThePTBArray[ CurrentTaskPointer + 1 ]^ :=
- ThePTBArray[ CurrentTaskPointer + 2 ]^;
- ThePTBArray[ CurrentTaskPointer + 2 ]^ := HoldingRecord;
- SetUpTheTaskbar;
- exit;
- end;
- end;
-
- procedure TCCTaskBarForm.MoveDown1Click(Sender: TObject);
- var HoldingRecord : TBRecord;
- begin
- if ActiveButton = BitBtn5 then
- begin
- if TotalTaskEntries = 0 then exit;
- if CurrentTaskPointer = TotalTaskEntries then exit;
- HoldingRecord := ThePTBArray[ CurrentTaskPointer + 1 ]^;
- ThePTBArray[ CurrentTaskPointer + 1 ]^ :=
- ThePTBArray[ CurrentTaskPointer ]^;
- ThePTBArray[ CurrentTaskPointer ]^ := HoldingRecord;
- SetUpTheTaskbar;
- exit;
- end;
- if ActiveButton = BitBtn6 then
- begin
- If CurrentTaskPointer + 1 >= TotalTaskEntries then exit;
- HoldingRecord := ThePTBArray[ CurrentTaskPointer + 2 ]^;
- ThePTBArray[ CurrentTaskPointer + 2 ]^ :=
- ThePTBArray[ CurrentTaskPointer + 1 ]^;
- ThePTBArray[ CurrentTaskPointer + 1 ]^ := HoldingRecord;
- SetUpTheTaskbar;
- exit;
- end;
- if ActiveButton = BitBtn7 then
- begin
- if CurrentTaskPointer + 2 >= TotalTaskEntries then exit;
- HoldingRecord := ThePTBArray[ CurrentTaskPointer + 3 ]^;
- ThePTBArray[ CurrentTaskPointer + 3 ]^ :=
- ThePTBArray[ CurrentTaskPointer + 2 ]^;
- ThePTBArray[ CurrentTaskPointer + 2 ]^ := HoldingRecord;
- SetUpTheTaskbar;
- exit;
- end;
- end;
-
- procedure TCCTaskBarForm.BitBtn5MouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- ActiveButton := BitBtn5;
- end;
-
- procedure TCCTaskBarForm.BitBtn6MouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- ActiveButton := BitBtn6;
- end;
-
- procedure TCCTaskBarForm.BitBtn7MouseDown(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- ActiveButton := BitBtn7;
- end;
-
- procedure TCCTaskBarForm.BitBtn5MouseUp(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- if Button = mbRight then PopupMenu2.PopUp( CCTaskBarForm.Left +
- BitBtn5.Left + 40 , CCTaskBarForm.Top + BitBtn5.Top - 40 );
- end;
-
- procedure TCCTaskBarForm.BitBtn6MouseUp(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- if Button = mbRight then PopupMenu2.PopUp( CCTaskBarForm.Left +
- BitBtn6.Left + 40 , CCTaskBarForm.Top + BitBtn6.Top - 40 );
- end;
-
- procedure TCCTaskBarForm.BitBtn7MouseUp(Sender: TObject;
- Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
- begin
- if Button = mbRight then PopupMenu2.PopUp( CCTaskBarForm.Left +
- BitBtn7.Left + 40 , CCTaskBarForm.Top + BitBtn7.Top - 40 );
- end;
-
- end.
-